package com.hyacinth.web.ui.easyui;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.serializer.SimplePropertyPreFilter;
import com.hyacinth.core.sysmgr.domain.SysMenu;

public class TreeGrid {
	
	
	
	public static String getMenuData1(List<SysMenu> list, Class<?> c, String[] fields) {
		SimplePropertyPreFilter spp = new SimplePropertyPreFilter(c, fields);
		Map<String,Object> map = new HashMap<String, Object>();
		map.put("total", list.size());
		map.put("rows", list);
		String str = JSON.toJSONString(map,spp,SerializerFeature.DisableCircularReferenceDetect);
		return str.replace("\"pid\"", "\"_parentId\"");
	}
	
	public static String getData2(List<?> list, Class<?> c, String[] fields) {
		SimplePropertyPreFilter spp = new SimplePropertyPreFilter(c, fields);
		String str = JSON.toJSONString(list,spp);
		return str.replace(",\"children\":[],", ",").replace("\"children\":[],", "");
	}
	
	public static String getData3(List<?> list) {
		return "";
	}
}
